package com.ujiuye.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration(proxyBeanMethods = false)
public class MyConfiguration {

    @Bean
    public WebMvcConfigurer corsConfigurer() {
        return new WebMvcConfigurer() {
            @Override
            public void addCorsMappings(CorsRegistry registry) {
                  /*
                addMapping("/**")  允许所有请求路径   所有域名
                .allowedMethods("*")    中默认只支持get与post的请求方式，允话所有请求方法  PUT,DELETE
                .allowedOrigins("*")    允许所有请求头信息
                 */
                registry.addMapping("/**").allowedMethods("*").allowedOrigins("*");
            }
        };
    }
}